package laspon.vvvlike.school.dto;


/**
 * @author xqcw9
 */

public enum ProductEnum {

    /**
     * 有效码值的枚举
     */
    VALID_STATUSY("1", "有效的"),
    /**
     * 无效码值的枚举
     */
    VALID_STATUSN("0", "无效的"),

    /**
     * 处理结果
     */
    SUCCESS("0000", "成功！"),
    EXCEPTION("9999", "系统异常!"),
    FAIL("9999", "失败！"),

    EXIT("9998", "已存在相同信息！"),
    NO_DATA("9998", "请输入数据!"),


    UPDATE_NOT_ID("9997", "更新操作,请输入id！"),
    DELETE_NOT_ID("9997", "删除操作,请输入id！"),


    ISPHONENUMBER("9999", "手机号错误，请核实再输入！");


    /**
     * 成员变量
     */
    private String code;
    private String name;


    private ProductEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * @param name 错误信息描述
     * @return 错误信息代码
     * @description 通过名称获取代码
     */
    public static String getCodeByName(String name) {
        for (ProductEnum info : ProductEnum.values()) {
            if (name.indexOf(info.getName()) > -1) {
                return info.getCode();
            }
        }
        return "9999";
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}
